home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / jmb.bst < prev    next >
Text File  |  1992-07-19  |  33KB  |  1,369 lines

  1. %%% ====================================================================
  2. %%%  @BibTeX-style-file{
  3. %%%     author          = "Tom Schneider",
  4. %%%     version         = "1.21",
  5. %%%     date            = "29 June 1992",
  6. %%%     time            = "17:30:33 MDT",
  7. %%%     filename        = "jmb.bst",
  8. %%%     address         = "National Cancer Institute
  9. %%%                        Laboratory of Mathematical Biology
  10. %%%                        Frederick, Maryland 21701-1013
  11. %%%                        USA",
  12. %%%     checksum        = "11681 1368 4735 33144",
  13. %%%     email           = "toms@ncifcrf.gov (Internet)",
  14. %%%     codetable       = "ISO/ASCII",
  15. %%%     keywords        = "molecular biology, BibTeX",
  16. %%%     supported       = "yes",
  17. %%%     docstring       = "This BibTeX bibliography style is for the
  18. %%%                        Journal of Molecular Biology and Journal of
  19. %%%                        Theoretical Biology.  This file is available
  20. %%%                        by anonymous ftp from ncifcrf.gov in
  21. %%%                        pub/delila.
  22. %%%
  23. %%%                        TITLES can be turned on and off!  Just nocite
  24. %%%                        the reference TitlesOn in the paper (i.e.
  25. %%%                        \nocite{TitlesOn}) and have a bibliography
  26. %%%                        article in your database with that cite key!
  27. %%%                        Without titles is Journal of Molecular
  28. %%%                        Biology; With titles is Journal of
  29. %%%                        Theoretical Biology.
  30. %%%
  31. %%%                        WARNING: Since I use mostly article, book and
  32. %%%                        inproceedings, these are formatted pretty
  33. %%%                        closely to the Journal of Theoretical Biology
  34. %%%                        style while other things are neglected.
  35. %%%                        Also, I can't guarantee that the style is
  36. %%%                        exactly right.
  37. %%%
  38. %%%                        The following documentation is identical from
  39. %%%                        the source of jmb.bst, which was the
  40. %%%                        apalike.bst taken from the Clarkson archive
  41. %%%                        on 1989 June 19.
  42. %%%
  43. %%%                        The checksum field above contains a CRC-16
  44. %%%                        checksum as the first value, followed by the
  45. %%%                        equivalent of the standard UNIX wc (word
  46. %%%                        count) utility output of lines, words, and
  47. %%%                        characters.  This is produced by Robert
  48. %%%                        Solovay's checksum utility."
  49. %%%  }
  50. %%% ====================================================================
  51.  
  52. % BibTex `jmb' bibliography style
  53. % version = 1.21 of jmb.bst 1992 June 29
  54. %                   Fix format.vol.num.pages to use field.or.null to
  55. %                   correctly handle case of missing volume.
  56. %                   [Nelson H. F. Beebe <beebe@plot79.math.utah.edu>]
  57. % version = 1.20 of jmb.bst 1990 November 16
  58.  
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  60. % BibTeX `apalike' bibliography style (24-Jan-88 version)
  61. % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
  62. % Copyright (C) 1988, all rights reserved.
  63. % Copying of this file is allowed, provided that if you make any changes at all
  64. % you name it something other than `apalike.bst'.
  65. % This restriction helps ensure that all copies are identical.
  66. % Differences between this style and `alpha' are generally heralded by a `%'.
  67. % The file btxbst.doc has the documentation for alpha.bst.
  68. %
  69. % This style should be used with the `apalike' LaTeX style (apalike.sty).
  70. % \cite's come out like "(Jones, 1986)" in the text but there are no labels
  71. % in the bibliography, and something like "(1986)" comes out immediately
  72. % after the author.  Author (and editor) names appear as last name, comma,
  73. % initials.  A `year' field is required for every entry, and so is either
  74. % an author (or in some cases, an editor) field or a key field.
  75. %
  76. % Editorial note:
  77. % Many journals require a style like `apalike', but I strongly, strongly,
  78. % strongly recommend that you not use it if you have a choice---use something
  79. % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
  80. % Knopf, 1979) argues convincingly that a style like `plain' encourages better
  81. % writing than one like `apalike'.  Furthermore the strongest arguments for
  82. % using an author-date style like `apalike'---that it's "the most practical"
  83. % (The Chicago Manual of Style, University of Chicago Press, thirteenth
  84. % edition, 1982, pages 400--401)---fall flat on their face with the new
  85. % computer-typesetting technology.  For instance page 401 anachronistically
  86. % states "The chief disadvantage of [a style like `plain'] is that additions
  87. % or deletions cannot be made after the manuscript is typed without changing
  88. % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
  89. %
  90. % History:
  91. %   15-sep-86    (SK,OP)    Original version, by Susan King and Oren Patashnik.
  92. %   10-nov-86    (OP)    Truncated the sort.key$ string to the correct length
  93. %            in bib.sort.order to eliminate error message.
  94. %   24-jan-88    (OP)    Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
  95. %            apalike now sorts by author, then year, then title;
  96. %            THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  97. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  98. %
  99. % The program was further modified by Tom Schneider:
  100. %
  101. %   1989 June 19 (TDS)  Renamed jmb.bst.  Items that do not have years were
  102. %        listed in the bibliography without identifiers.  However, they
  103. %        have identifiers in the text.  The identifier was added.
  104. %        Titles were removed :-(.
  105.  
  106. %   1989 October 2 (TDS)  Made labels in the paper use the & symbol rather
  107. %                  than `and', as required by JMB.
  108. %   1989 October 3 (TDS)  Made et~al. be in italics.
  109. %                  Removed comma after journal name.  (actually, all
  110. %                  mid sentence commas go!)
  111. %                  Made volume number be bold faced.
  112. %                  Converted colon (:) after volume number to a comma (,).
  113. %                  If a journal name does NOT end in a period, add
  114. %                  a comma after the name.
  115. %   1989 October 14 (TDS)  Without a year the program used to sort on the
  116. %                   title.  I made it sort on the cite$ if there is no year.
  117. %   1989 October 18 (TDS)  If there is one reference without a year, put
  118. %                   an "a" at the end of its label, so that it comes out
  119. %                   as (Smith, a) in the text.  in FUNCTION {forward.pass}
  120. %   1989 November 2 (TDS)  Unpublished papers now give the title.
  121. %   1989 November 18 (TDS)  TITLES can be turned on and off!
  122. %                   Just nocite the reference TitlesOn in the paper
  123. %                   and have a bibliography article in your database
  124. %                   with that cite key!
  125. %   1989 December 5 (TDS)  I can't stand sorting to fall back on the
  126. %                   titles of the article - no control!  So in function
  127. %                   bib.sort.order the default is now cite$.
  128. %   1990 November 14 (TDS) Changes to match JTB better:
  129. %                    Names in the bibliography are now connected
  130. %                    with "\&" instead of "and", since this fits JTB better.
  131. %                    "In" is now "In:".
  132. %                    "editors" and "editor" are now "eds" and "ed".
  133. %                    booktitle follows editors.  editors in parenthesis.
  134. %                    pp. and p. instead of pages and page.
  135. %                    location followed by colon (:) and then publisher.
  136.  
  137. ENTRY  % declare variables that have a value for each entry on the list
  138.   { address
  139.     author
  140.     booktitle
  141.     chapter
  142.     edition
  143.     editor
  144.     howpublished
  145.     institution
  146.     journal
  147.     key
  148. %    month        not used in apalike
  149.     note
  150.     number
  151.     organization
  152.     pages
  153.     publisher
  154.     school
  155.     series
  156.     title
  157.     type
  158.     volume
  159.     year
  160.   }
  161.   {}
  162.   { label extra.label sort.label }
  163.  
  164. INTEGERS { output.state before.all mid.sentence after.sentence after.block
  165.            docomma givetitles }
  166.  
  167. FUNCTION {init.state.consts}
  168. { #0 'before.all :=
  169.   #1 'mid.sentence :=
  170.   #2 'after.sentence :=
  171.   #3 'after.block :=
  172.  
  173.   #0 'docomma :=    % if it is 0 then don't do commas, otherwise do them.
  174. }
  175.  
  176. FUNCTION {init.toggle.switches}
  177. {% set switches for controlling the output!
  178.   #0 'givetitles := % if it is 0 then don't give titles, otherwise do them.
  179. }
  180.  
  181. STRINGS { s t }
  182.  
  183. FUNCTION {output.nonnull}
  184. { 's :=
  185.   output.state mid.sentence =
  186.  
  187. % %    { ", " * write$ }  % the comma here is responsible for every comma!
  188. % %                       % But JMB doesn't want commas, so away it goes!
  189. %      { " " * write$ }    % That does it!
  190.  
  191.     { % doing a comma is controlled specifically in JMB using docomma
  192.       docomma #0 =
  193.       { " " * write$ }
  194.       { ", " * write$ }
  195.       if$
  196.     }
  197.     { output.state after.block =
  198.     { add.period$ write$
  199.       newline$
  200.       "\newblock " write$
  201.     }
  202.     { output.state before.all =
  203.         'write$
  204.         { add.period$ " " * write$ }
  205.       if$
  206.     }
  207.       if$
  208.       mid.sentence 'output.state :=
  209.     }
  210.   if$
  211.   s
  212. }
  213.  
  214. FUNCTION {output}
  215. { duplicate$ empty$
  216.     'pop$
  217.     'output.nonnull
  218.   if$
  219. }
  220.  
  221. FUNCTION {output.check}
  222. { 't :=
  223.   duplicate$ empty$
  224.      {  t "title" =
  225.            { pop$ } % jmb ignores titles and does not object if missing
  226.            { pop$ "empty " t * " in " * cite$ * warning$ }
  227.         if$
  228.      }
  229.     'output.nonnull  % block periods
  230.     % { pop$  } % don't do anything
  231.   if$
  232. }
  233.  
  234. %    t "title" =
  235. %    { "zowie" warning$ }
  236. %    {  duplicate$ empty$
  237. %       { pop$ "EmPtY " t * " in " * cite$ * warning$ }
  238. %       'output.nonnull
  239. %    }
  240. %    if$
  241. %  if$
  242. %}
  243.  
  244. %                    apalike needs this function because
  245. %                    the year has special punctuation;
  246. %                    apalike ignores the month
  247. FUNCTION {output.year.check}
  248. { year empty$
  249.     {
  250.       "empty year in " cite$ ", using label: " extra.label * * * warning$
  251.       write$
  252.       " (" extra.label * ")" *
  253.       mid.sentence 'output.state :=
  254.     }
  255.     { write$
  256.       " (" year * extra.label * ")" *
  257.       mid.sentence 'output.state :=
  258.     }
  259.   if$
  260. }
  261.  
  262. FUNCTION {output.bibitem}
  263. { newline$
  264.   "\bibitem[" write$
  265.   label write$
  266.   "]{" write$
  267.   cite$ write$
  268.   "}" write$
  269.   newline$
  270.   ""
  271.   before.all 'output.state :=
  272. }
  273.  
  274. FUNCTION {fin.entry}
  275. { add.period$
  276.   write$
  277.   newline$
  278. }
  279.  
  280. FUNCTION {new.block}
  281. { output.state before.all =
  282.     'skip$
  283.     { after.block 'output.state := }
  284.   if$
  285. }
  286.  
  287. FUNCTION {new.sentence}
  288. { output.state after.block =
  289.     'skip$
  290.     { output.state before.all =
  291.     'skip$
  292.     { after.sentence 'output.state := }
  293.       if$
  294.     }
  295.   if$
  296. }
  297.  
  298. FUNCTION {not}
  299. {   { #0 }
  300.     { #1 }
  301.   if$
  302. }
  303.  
  304. FUNCTION {and}
  305. {   'skip$
  306.     { pop$ #0 }
  307.   if$
  308. }
  309.  
  310. FUNCTION {or}
  311. {   { pop$ #1 }
  312.     'skip$
  313.   if$
  314. }
  315.  
  316. FUNCTION {new.block.checkb}
  317. { empty$
  318.   swap$ empty$
  319.   and
  320.     'skip$
  321.     'new.block
  322.   if$
  323. }
  324.  
  325. FUNCTION {field.or.null}
  326. { duplicate$ empty$
  327.     { pop$ "" }
  328.     'skip$
  329.   if$
  330. }
  331.  
  332. FUNCTION {emphasize}
  333. { duplicate$ empty$
  334.     { pop$ "" }
  335.     { "{\em " swap$ * "}" * }
  336.   if$
  337. }
  338.  
  339. INTEGERS { nameptr namesleft numnames }
  340.  
  341. FUNCTION {format.names}
  342. { 's :=
  343.   #1 'nameptr :=
  344.   s num.names$ 'numnames :=
  345.   numnames 'namesleft :=
  346.     { namesleft #0 > }
  347.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  348.       nameptr #1 >
  349.     { namesleft #1 >
  350.         { ", " * t * }
  351.         { numnames #2 >
  352.         { "," * }
  353.         'skip$
  354.           if$
  355.           t "others" =
  356.         { " {\em et~al.}" * }
  357.         { " \& " * t * }
  358.           if$
  359.         }
  360.       if$
  361.     }
  362.     't
  363.       if$
  364.       nameptr #1 + 'nameptr :=
  365.       namesleft #1 - 'namesleft :=
  366.     }
  367.   while$
  368. }
  369.  
  370. FUNCTION {format.authors}
  371. { author empty$
  372.     { "" }
  373.     { author format.names }
  374.   if$
  375. }
  376.  
  377. FUNCTION {format.key}            % this function is just for apalike
  378. { empty$
  379.     { key field.or.null }
  380.     { "" }
  381.   if$
  382. }
  383.  
  384. FUNCTION {format.editors}
  385. { editor empty$
  386.     { "" }
  387.     { editor format.names
  388.       editor num.names$ #1 >
  389.     { ", eds" * } % TDS
  390.     { ", ed" * } % TDS
  391.       if$
  392.     }
  393.   if$
  394. }
  395.  
  396. FUNCTION {format.title}
  397. { title empty$
  398.     { "" }
  399.     { % decide whether to give the title or not
  400.        givetitles #1 =
  401.        { title "t" change.case$ } % produce the title
  402.        { title pop$ "" }          % don't produce the title
  403.        if$
  404.     }
  405.   if$
  406. }
  407.  
  408. FUNCTION {n.dashify}
  409. { 't :=
  410.   ""
  411.     { t empty$ not }
  412.     { t #1 #1 substring$ "-" =
  413.     { t #1 #2 substring$ "--" = not
  414.         { "--" *
  415.           t #2 global.max$ substring$ 't :=
  416.         }
  417.         {   { t #1 #1 substring$ "-" = }
  418.         { "-" *
  419.           t #2 global.max$ substring$ 't :=
  420.         }
  421.           while$
  422.         }
  423.       if$
  424.     }
  425.     { t #1 #1 substring$ *
  426.       t #2 global.max$ substring$ 't :=
  427.     }
  428.       if$
  429.     }
  430.   while$
  431. }
  432.  
  433. FUNCTION {format.btitle}
  434. { title emphasize
  435. }
  436.  
  437. FUNCTION {tie.or.space.connect}
  438. { duplicate$ text.length$ #3 <
  439.     { "~" }
  440.     { " " }
  441.   if$
  442.   swap$ * *
  443. }
  444.  
  445. FUNCTION {either.or.check}
  446. { empty$
  447.     'pop$
  448.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  449.   if$
  450. }
  451.  
  452. FUNCTION {format.bvolume}
  453. { volume empty$
  454.     { "" }
  455.     { "volume" volume tie.or.space.connect
  456.       series empty$
  457.     'skip$
  458.     { " of " * series emphasize * }
  459.       if$
  460.       "volume and number" number either.or.check
  461.     }
  462.   if$
  463. }
  464.  
  465. FUNCTION {format.number.series}
  466. { volume empty$
  467.     { number empty$
  468.     { series field.or.null }
  469.     { output.state mid.sentence =
  470.         { "number" }
  471.         { "Number" }
  472.       if$
  473.       number tie.or.space.connect
  474.       series empty$
  475.         { "there's a number but no series in " cite$ * warning$ }
  476.         { " in " * series * }
  477.       if$
  478.     }
  479.       if$
  480.     }
  481.     { "" }
  482.   if$
  483. }
  484.  
  485. FUNCTION {format.edition}
  486. { edition empty$
  487.     { "" }
  488.     { output.state mid.sentence =
  489.     { edition "l" change.case$ " edition" * }
  490.     { edition "t" change.case$ " edition" * }
  491.       if$
  492.     }
  493.   if$
  494. }
  495.  
  496. INTEGERS { multiresult }
  497.  
  498. FUNCTION {multi.page.check}
  499. { 't :=
  500.   #0 'multiresult :=
  501.     { multiresult not
  502.       t empty$ not
  503.       and
  504.     }
  505.     { t #1 #1 substring$
  506.       duplicate$ "-" =
  507.       swap$ duplicate$ "," =
  508.       swap$ "+" =
  509.       or or
  510.     { #1 'multiresult := }
  511.     { t #2 global.max$ substring$ 't := }
  512.       if$
  513.     }
  514.   while$
  515.   multiresult
  516. }
  517.  
  518. FUNCTION {format.pages}
  519. { pages empty$
  520.     { "" }
  521.     { pages multi.page.check
  522.     { "pp." pages n.dashify tie.or.space.connect } % TDS
  523.     { "p." pages tie.or.space.connect } % TDS
  524.       if$
  525.     }
  526.   if$
  527. }
  528.  
  529. FUNCTION {format.vol.num.pages}
  530. { "{\bf " volume field.or.null * "}" *  % make volume bold face
  531.   number empty$
  532.     'skip$
  533.     { " (" number * ")" * *
  534.        volume empty$
  535.     { "there's a number but no volume in " cite$ * warning$ }
  536.     'skip$
  537.       if$
  538.     }
  539.   if$
  540.   pages empty$
  541.     'skip$
  542.     { duplicate$ empty$
  543.     { pop$ format.pages }
  544. %    { ":" * pages n.dashify * } % no more colons after the volume
  545.     { ", " * pages n.dashify * } % comma's instead
  546.       if$
  547.     }
  548.   if$
  549. }
  550.  
  551. FUNCTION {format.chapter.pages}
  552. { chapter empty$
  553.     'format.pages
  554.     { type empty$
  555.     { "chapter" }
  556.     { type "l" change.case$ }
  557.       if$
  558.       chapter tie.or.space.connect
  559.       pages empty$
  560.     'skip$
  561.     { ", " * format.pages * }
  562.       if$
  563.     }
  564.   if$
  565. }
  566.  
  567. FUNCTION {format.in.ed.booktitle}
  568. { booktitle empty$
  569.     { "" }
  570.     { editor empty$
  571.     { "In: " booktitle emphasize * } % TDS
  572.     { "In: " booktitle emphasize * ", " *
  573.           "(" format.editors ")" * * * } % TDS
  574.       if$
  575.     }
  576.   if$
  577. }
  578.  
  579. FUNCTION {format.thesis.type}
  580. { type empty$
  581.     'skip$
  582.     { pop$
  583.       type "t" change.case$
  584.     }
  585.   if$
  586. }
  587.  
  588. FUNCTION {format.tr.number}
  589. { type empty$
  590.     { "Technical Report" }
  591.     'type
  592.   if$
  593.   number empty$
  594.     { "t" change.case$ }
  595.     { number tie.or.space.connect }
  596.   if$
  597. }
  598.  
  599. FUNCTION {format.article.crossref}
  600. { "In:"                % this is for apalike % TDS
  601.   " \cite{" * crossref * "}" *
  602. }
  603.  
  604. FUNCTION {format.book.crossref}
  605. { volume empty$
  606.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  607.       "In: " % TDS
  608.     }
  609.     { "Volume" volume tie.or.space.connect
  610.       " of " *
  611.     }
  612.   if$
  613.   "\cite{" * crossref * "}" *                % this is for apalike
  614. }
  615.  
  616. FUNCTION {format.incoll.inproc.crossref}
  617. { "In:"                % this is for apalike % TDS
  618.   " \cite{" * crossref * "}" *
  619. }
  620.  
  621. FUNCTION {article}
  622. {
  623.   cite$ "TitlesOn" =
  624.   'skip$ % Don't write out an article of this kind, it's a toggle switch!
  625.   {
  626.   output.bibitem
  627.   format.authors "author" output.check
  628.   author format.key output                % special for
  629.   output.year.check                    % apalike
  630.   new.block
  631.   format.title "title" output.check
  632.   new.block
  633.   crossref missing$
  634.     { % figure out the last character of the journal name.
  635.       % "<<" journal #-1 #1 substring$ ">>" * *  % for testing
  636.       % "<" journal ">" * *  % this works ok     % for testing
  637.  
  638.       journal #-1 #1 substring$ "." =
  639.       { journal }  % journal ended in period so don't do anything
  640.       { journal ", " *}  % journal ended without period, so add comma
  641.       if$
  642.       emphasize "journal" output.check
  643.  
  644. %      journal * emphasize "journal" output.check % the original method
  645.  
  646.       format.vol.num.pages output
  647.     }
  648.     { format.article.crossref output.nonnull
  649.       format.pages output
  650.     }
  651.   if$
  652.   new.block
  653.   note output
  654.   fin.entry
  655.   }
  656.   if$
  657. }
  658.  
  659. FUNCTION {book}
  660. { output.bibitem
  661.   author empty$
  662.     { format.editors "author and editor" output.check
  663.       editor format.key output
  664.     }
  665.     { format.authors output.nonnull
  666.       crossref missing$
  667.     { "author and editor" editor either.or.check }
  668.     'skip$
  669.       if$
  670.     }
  671.   if$
  672.   output.year.check                % special for apalike
  673.   new.block
  674.   format.btitle "title" output.check
  675.   #1 'docomma :=    % TURN COMMAS ON FOR JMB
  676.   crossref missing$
  677.     {
  678.       format.bvolume output
  679.       new.block
  680.       format.number.series output
  681.       new.sentence
  682.          #0 'docomma := % no comma after address
  683.       address ":" * output % TDS
  684.       publisher "publisher" output.check % TDS
  685.          #1 'docomma := % comma back on
  686. %      publisher "publisher" output.check
  687. %      address output
  688.     }
  689.     { new.block
  690.       format.book.crossref output.nonnull
  691.     }
  692.   if$
  693.   format.edition output
  694.   new.block
  695.   note output
  696.   fin.entry
  697.   #0 'docomma :=    % TURN COMMAS OFF
  698. }
  699.  
  700. FUNCTION {booklet}
  701. { output.bibitem
  702.   format.authors output
  703.   author format.key output                % special for
  704.   output.year.check                    % apalike
  705.   new.block
  706.   format.title "title" output.check
  707.   new.block
  708.   howpublished output
  709.   address output
  710.   new.block
  711.   note output
  712.   fin.entry
  713. }
  714.  
  715. FUNCTION {inbook}
  716. { output.bibitem
  717.   author empty$
  718.     { format.editors "author and editor" output.check
  719.       editor format.key output
  720.     }
  721.     { format.authors output.nonnull
  722.       crossref missing$
  723.     { "author and editor" editor either.or.check }
  724.     'skip$
  725.       if$
  726.     }
  727.   if$
  728.   output.year.check                % special for apalike
  729.   new.block
  730.   format.btitle "title" output.check
  731.   crossref missing$
  732.     { format.bvolume output
  733.       format.chapter.pages "chapter and pages" output.check
  734.       new.block
  735.       format.number.series output
  736.       new.sentence
  737.          #0 'docomma := % no comma after address
  738.       address ":" * output % TDS
  739.       publisher "publisher" output.check % TDS
  740.          #1 'docomma := % comma back on
  741. %      publisher "publisher" output.check
  742. %      address output
  743.     }
  744.     { format.chapter.pages "chapter and pages" output.check
  745.       new.block
  746.       format.book.crossref output.nonnull
  747.     }
  748.   if$
  749.   format.edition output
  750.   new.block
  751.   note output
  752.   fin.entry
  753. }
  754.  
  755. FUNCTION {incollection}
  756. { output.bibitem
  757.   format.authors "author" output.check
  758.   author format.key output                % special for
  759.   output.year.check                    % apalike
  760.   new.block
  761.   format.title "title" output.check
  762.   new.block
  763.   crossref missing$
  764.     { format.in.ed.booktitle "booktitle" output.check
  765.       format.bvolume output
  766.       format.number.series output
  767.       format.chapter.pages output
  768.       new.sentence
  769.       publisher "publisher" output.check
  770.       address output
  771.       format.edition output
  772.     }
  773.     { format.incoll.inproc.crossref output.nonnull
  774.       format.chapter.pages output
  775.     }
  776.   if$
  777.   new.block
  778.   note output
  779.   fin.entry
  780. }
  781.  
  782. FUNCTION {inproceedings}
  783. { output.bibitem
  784.   format.authors "author" output.check
  785.   author format.key output                % special for
  786.   output.year.check                    % apalike
  787.   new.block
  788.   format.title "title" output.check
  789.   new.block
  790.   crossref missing$
  791.     {
  792. %      #1 'docomma :=    % TURN COMMAS ON FOR JMB, BUT NOT FOR JTB: inconsistent
  793.       format.in.ed.booktitle "booktitle" output.check
  794.       format.bvolume output
  795.       format.number.series output
  796.       format.pages "," * output % TDS toss in comma instead of period
  797. %      address output % TDS address is below for JTB
  798. %      new.sentence % TDS remove period
  799.       organization output
  800.          #0 'docomma := % NO COMMA AFTER ADDRESS
  801.       address ":" * output % TDS
  802.       publisher "publisher" output.check % TDS
  803.          #1 'docomma := % comma back on
  804.  
  805. %      publisher output                    % are simpler
  806.       #0 'docomma :=    % TURN COMMAS OFF
  807.     }
  808.     { format.incoll.inproc.crossref output.nonnull
  809.       format.pages output
  810.     }
  811.   if$
  812.   new.block
  813.   note output
  814.   fin.entry
  815. }
  816.  
  817. FUNCTION {conference} { inproceedings }
  818.  
  819. FUNCTION {manual}
  820. { output.bibitem
  821.   format.authors output
  822.   author format.key output                % special for
  823.   output.year.check                    % apalike
  824.   new.block
  825.   format.btitle "title" output.check
  826.   organization address new.block.checkb
  827.   organization output
  828.   address output
  829.   format.edition output
  830.   new.block
  831.   note output
  832.   fin.entry
  833. }
  834.  
  835. FUNCTION {mastersthesis}
  836. { output.bibitem
  837.   format.authors "author" output.check
  838.   author format.key output                % special for
  839.   output.year.check                    % apalike
  840.   new.block
  841.   format.title "title" output.check
  842.   new.block
  843.   "Master's thesis" format.thesis.type output.nonnull
  844.   school "school" output.check
  845.   address output
  846.   new.block
  847.   note output
  848.   fin.entry
  849. }
  850.  
  851. FUNCTION {misc}
  852. { output.bibitem
  853.   format.authors output
  854.   author format.key output                % special for
  855.   output.year.check                    % apalike
  856.   new.block
  857.   format.title output
  858.   new.block
  859.   howpublished output
  860.   new.block
  861.   note output
  862.   fin.entry
  863. }
  864.  
  865. FUNCTION {phdthesis}
  866. { output.bibitem
  867.   format.authors "author" output.check
  868.   author format.key output                % special for
  869.   output.year.check                    % apalike
  870.   new.block
  871.   format.btitle "title" output.check
  872.   new.block
  873.   "PhD thesis" format.thesis.type output.nonnull
  874.   school "school" output.check
  875.   address output
  876.   new.block
  877.   note output
  878.   fin.entry
  879. }
  880.  
  881. FUNCTION {proceedings}
  882. { output.bibitem
  883.   format.editors output
  884.   editor format.key output                % special for
  885.   output.year.check                    % apalike
  886.   new.block
  887.   format.btitle "title" output.check
  888.   format.bvolume output
  889.   format.number.series output
  890.   address output                % for apalike
  891.   new.sentence                    % we always output
  892.   organization output                % a nonempty organization
  893.   publisher output                % here
  894.   new.block
  895.   note output
  896.   fin.entry
  897. }
  898.  
  899. FUNCTION {techreport}
  900. { output.bibitem
  901.   format.authors "author" output.check
  902.   author format.key output                % special for
  903.   output.year.check                    % apalike
  904.   new.block
  905.   format.title "title" output.check
  906.   new.block
  907.   format.tr.number output.nonnull
  908.   institution "institution" output.check
  909.   address output
  910.   new.block
  911.   note output
  912.   fin.entry
  913. }
  914.  
  915. FUNCTION {unpublished}
  916. { output.bibitem
  917.   format.authors "author" output.check
  918.   author format.key output                % special for
  919.   output.year.check                    % apalike
  920.   new.block
  921.  
  922. % Since format.title is out of commission, the original method won't work:
  923. %  format.title "title" output.check
  924. % so do the equivalent of the format.title procedure: (TDS)
  925.   title empty$
  926.     { "" }
  927.     { title "t" change.case$ } % produce the title
  928.   if$
  929.   "title" output.check
  930.  
  931.   new.block
  932.   note "note" output.check
  933.   fin.entry
  934. }
  935.  
  936. FUNCTION {default.type} { misc }
  937.  
  938. MACRO {jan} {"January"}
  939.  
  940. MACRO {feb} {"February"}
  941.  
  942. MACRO {mar} {"March"}
  943.  
  944. MACRO {apr} {"April"}
  945.  
  946. MACRO {may} {"May"}
  947.  
  948. MACRO {jun} {"June"}
  949.  
  950. MACRO {jul} {"July"}
  951.  
  952. MACRO {aug} {"August"}
  953.  
  954. MACRO {sep} {"September"}
  955.  
  956. MACRO {oct} {"October"}
  957.  
  958. MACRO {nov} {"November"}
  959.  
  960. MACRO {dec} {"December"}
  961.  
  962. MACRO {acmcs} {"ACM Computing Surveys"}
  963.  
  964. MACRO {acta} {"Acta Informatica"}
  965.  
  966. MACRO {cacm} {"Communications of the ACM"}
  967.  
  968. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  969.  
  970. MACRO {ibmsj} {"IBM Systems Journal"}
  971.  
  972. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  973.  
  974. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  975.  
  976. MACRO {ieeetcad}
  977.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  978.  
  979. MACRO {ipl} {"Information Processing Letters"}
  980.  
  981. MACRO {jacm} {"Journal of the ACM"}
  982.  
  983. MACRO {jcss} {"Journal of Computer and System Sciences"}
  984.  
  985. MACRO {scp} {"Science of Computer Programming"}
  986.  
  987. MACRO {sicomp} {"SIAM Journal on Computing"}
  988.  
  989. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  990.  
  991. MACRO {tods} {"ACM Transactions on Database Systems"}
  992.  
  993. MACRO {tog} {"ACM Transactions on Graphics"}
  994.  
  995. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  996.  
  997. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  998.  
  999. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1000.  
  1001. MACRO {tcs} {"Theoretical Computer Science"}
  1002.  
  1003. READ
  1004.  
  1005. % ***********************************************************
  1006.  
  1007. FUNCTION {check.for.titlecommand}
  1008. % go through each entry and see if one of them has the key
  1009. % 'TitlesOn'.  If this is found, then do titles!
  1010. % 1989 November 18 TDS
  1011. {
  1012. %  "|" label "|" * * write$ newline$  % |Arrhenius {\em et~al.}, 1986|
  1013. %  "|" cite$ "|" * * write$ newline$  % |Arrhenius1986|
  1014. % so cite$ is the thing I want to detect...
  1015.  
  1016.   cite$ "TitlesOn" =
  1017.   { % got it!
  1018. %    "FOUND TitlesOn" write$ newline$
  1019.      "Titles Will Be Printed" warning$
  1020.     #1 'givetitles := % give titles!
  1021.   }
  1022.   'skip$
  1023.   if$
  1024. }
  1025. EXECUTE {init.toggle.switches}
  1026. ITERATE {check.for.titlecommand}
  1027. % ***********************************************************
  1028.  
  1029. FUNCTION {sortify}
  1030. { purify$
  1031.   "l" change.case$
  1032. }
  1033.  
  1034. INTEGERS { len }
  1035.  
  1036. FUNCTION {chop.word}
  1037. { 's :=
  1038.   'len :=
  1039.   s #1 len substring$ =
  1040.     { s len #1 + global.max$ substring$ }
  1041.     's
  1042.   if$
  1043. }
  1044.  
  1045. %            There are three apalike cases: one person (Jones),
  1046. %            two (Jones and de~Bruijn), and more (Jones et~al.).
  1047. %            This function is much like format.crossref.editors.
  1048. %
  1049. FUNCTION {format.lab.names}
  1050. { 's :=
  1051.   s #1 "{vv~}{ll}" format.name$
  1052.   s num.names$ duplicate$
  1053.   #2 >
  1054.     { pop$ " {\em et~al.}" * }
  1055.     { #2 <
  1056.     'skip$
  1057.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1058.         { " {\em et~al.}" * }
  1059.         { " \& " * s #2 "{vv~}{ll}" format.name$ * }
  1060.             % note new use of & rather than `and'.  TDS
  1061.       if$
  1062.     }
  1063.       if$
  1064.     }
  1065.   if$
  1066. }
  1067.  
  1068. FUNCTION {author.key.label}
  1069. { author empty$
  1070.     { key empty$
  1071.     { cite$ #1 #3 substring$ }
  1072.     'key                    % apalike uses the whole key
  1073.       if$
  1074.     }
  1075.     { author format.lab.names }
  1076.   if$
  1077. }
  1078.  
  1079. FUNCTION {author.editor.key.label}
  1080. { author empty$
  1081.     { editor empty$
  1082.     { key empty$
  1083.         { cite$ #1 #3 substring$ }
  1084.         'key                % apalike uses the whole key
  1085.       if$
  1086.     }
  1087.     { editor format.lab.names }
  1088.       if$
  1089.     }
  1090.     { author format.lab.names }
  1091.   if$
  1092. }
  1093.  
  1094. FUNCTION {editor.key.label}
  1095. { editor empty$
  1096.     { key empty$
  1097.     { cite$ #1 #3 substring$ }
  1098.     'key            % apalike uses the whole key, no organization
  1099.       if$
  1100.     }
  1101.     { editor format.lab.names }
  1102.   if$
  1103. }
  1104.  
  1105. FUNCTION {calc.label}
  1106. { type$ "book" =
  1107.   type$ "inbook" =
  1108.   or
  1109.     'author.editor.key.label
  1110.     { type$ "proceedings" =
  1111.     'editor.key.label            % apalike ignores organization
  1112.     'author.key.label            % for labeling and sorting
  1113.       if$
  1114.     }
  1115.   if$
  1116.   ", "                            % these three lines are
  1117.   *                            % for apalike, which
  1118.   year field.or.null purify$ #-1 #4 substring$        % uses all four digits
  1119.   *
  1120.   'label :=
  1121. }
  1122.  
  1123. FUNCTION {sort.format.names}
  1124. { 's :=
  1125.   #1 'nameptr :=
  1126.   ""
  1127.   s num.names$ 'numnames :=
  1128.   numnames 'namesleft :=
  1129.     { namesleft #0 > }
  1130.     { nameptr #1 >
  1131.     { "   " * }
  1132.     'skip$
  1133.       if$                        % apalike uses initials
  1134.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  1135.       nameptr numnames = t "others" = and
  1136.     { "{\em et al}" * }
  1137.     { t sortify * }
  1138.       if$
  1139.       nameptr #1 + 'nameptr :=
  1140.       namesleft #1 - 'namesleft :=
  1141.     }
  1142.   while$
  1143. }
  1144.  
  1145. FUNCTION {sort.format.title}
  1146. { 't :=
  1147.   "A " #2
  1148.     "An " #3
  1149.       "The " #4 t chop.word
  1150.     chop.word
  1151.   chop.word
  1152.   sortify
  1153.   #1 global.max$ substring$
  1154. }
  1155.  
  1156. FUNCTION {author.sort}
  1157. { author empty$
  1158.     { key empty$
  1159.     { "to sort, need author or key in " cite$ * warning$
  1160.       ""
  1161.     }
  1162.     { key sortify }
  1163.       if$
  1164.     }
  1165.     { author sort.format.names }
  1166.   if$
  1167. }
  1168.  
  1169. FUNCTION {author.editor.sort}
  1170. { author empty$
  1171.     { editor empty$
  1172.     { key empty$
  1173.         { "to sort, need author, editor, or key in " cite$ * warning$
  1174.           ""
  1175.         }
  1176.         { key sortify }
  1177.       if$
  1178.     }
  1179.     { editor sort.format.names }
  1180.       if$
  1181.     }
  1182.     { author sort.format.names }
  1183.   if$
  1184. }
  1185.  
  1186. FUNCTION {editor.sort}
  1187. { editor empty$
  1188.     { key empty$
  1189.     { "to sort, need editor or key in " cite$ * warning$
  1190.       ""
  1191.     }
  1192.     { key sortify }
  1193.       if$
  1194.     }
  1195.     { editor sort.format.names }
  1196.   if$
  1197. }
  1198.  
  1199. %            apalike uses two sorting passes; the first one sets the
  1200. %            labels so that the `a's, `b's, etc. can be computed;
  1201. %            the second pass puts the references in "correct" order.
  1202. %            The presort function is for the first pass. It computes
  1203. %            label, sort.label, and title, and then concatenates.
  1204. FUNCTION {presort}
  1205. { calc.label
  1206.   label sortify
  1207.   "    "
  1208.   *
  1209.   type$ "book" =
  1210.   type$ "inbook" =
  1211.   or
  1212.     'author.editor.sort
  1213.     { type$ "proceedings" =
  1214.     'editor.sort
  1215.     'author.sort
  1216.       if$
  1217.     }
  1218.   if$
  1219.   #1 entry.max$ substring$    % for
  1220.   'sort.label :=        % apalike
  1221.   sort.label            % style
  1222.   *
  1223.   "    "
  1224.   *
  1225.   title field.or.null
  1226.   sort.format.title
  1227.   *
  1228.   #1 entry.max$ substring$
  1229.   'sort.key$ :=
  1230. }
  1231.  
  1232. ITERATE {presort}
  1233.  
  1234. SORT        % by label, sort.label, title---for final label calculation
  1235.  
  1236. STRINGS { last.label next.extra }    % apalike labels are only for the text;
  1237.  
  1238. INTEGERS { last.extra.num }        % there are none in the bibliography
  1239.  
  1240. FUNCTION {initialize.extra.label.stuff}    % and hence there is no `longest.label'
  1241. { #0 int.to.chr$ 'last.label :=
  1242.   "" 'next.extra :=
  1243.   #0 'last.extra.num :=
  1244. }
  1245.  
  1246. FUNCTION {forward.pass}
  1247. % pass through the references forward
  1248. {
  1249. %"\\     label=" label "//" * * write$ newline$ % display the label
  1250. %"\\last.label=" last.label "//" * * write$ newline$ % display the label
  1251.  
  1252.  last.label label =   % if the label repeats the previous label...
  1253.     { % then increment the extra number
  1254.       last.extra.num #1 + 'last.extra.num :=
  1255.       % and convert it to a label
  1256.       last.extra.num int.to.chr$ 'extra.label :=
  1257.     }
  1258.     { % else set things up for the next entry
  1259.       "a" chr.to.int$ 'last.extra.num :=
  1260.  
  1261.       % However, if the year was missing, tack on an extra "a". TDS
  1262.       year empty$
  1263.       {"a" 'extra.label :=}
  1264.       {"" 'extra.label :=}
  1265.       if$
  1266.  
  1267. %      "" 'extra.label :=  % the original method was not to do anything TDS
  1268.  
  1269.       label 'last.label :=   % capture this label for next time
  1270.     }
  1271.   if$
  1272. %"\\extra.label = " extra.label "//" * * write$ newline$ % display the label
  1273. }
  1274.  
  1275. FUNCTION {reverse.pass}
  1276. % pass through the references backwards
  1277. % add extra characters to the end of the label string
  1278. {
  1279. %"{{" label "}}" * * write$ newline$ % display the label
  1280.  next.extra "b" =
  1281. % original logic:
  1282.     { "a" 'extra.label := }
  1283.     'skip$
  1284.     if$
  1285.  
  1286. % next.extra "b" = { "next.extra was = b" write$ newline$} 'skip$ if$
  1287.  
  1288. % new as of 1989 Oct 18
  1289. %    { "a" 'extra.label := }
  1290. %    { % Put on an "a" at the end of the label if the year is missing. TDS
  1291. %      year empty$
  1292. %       { "a" 'extra.label := }
  1293. %       %{ label "a" * 'label := }
  1294. %       'skip$ % otherwise leave it alone (orignial method)
  1295. %     if$ }
  1296. %  if$
  1297.  
  1298.   label extra.label * 'label :=
  1299.   extra.label 'next.extra :=
  1300. %"{{" label "}}" * * write$ newline$ % display the label
  1301. }
  1302.  
  1303. FUNCTION {bib.sort.order}
  1304. % Generate the sort.key$ variables for sorting.
  1305. % The sorting is first on the sort.label (ie, author's name), followed
  1306. % by the year then the title.  If there is no year, the cite$ is used.
  1307. {
  1308.   sort.label  % this is based on the author name
  1309.   "    " * % tack on some space
  1310. % original apa command was to use the year or an empty string:
  1311. %  year field.or.null sortify
  1312. %
  1313. % Replace that with the use of the cite$, when there is no year:
  1314.   year duplicate$ empty$
  1315.      {pop$ cite$}
  1316.      'skip$
  1317.   if$
  1318.  
  1319.   * "    " *  % tack on some space
  1320.  
  1321. % I CAN'T STAND SORTING ON TITLE!!! TDS 1989 Dec 5
  1322. %  title field.or.null
  1323. %  sort.format.title
  1324. %  * % attach them together
  1325.   cite$
  1326.   * % use cite$ instead!!
  1327.  
  1328.   % note: if there is no year, then the cite$ will override the sorting
  1329.   % on the title.  Oh well.  Title sorting is sorta (ha ha) awful.
  1330.  
  1331.   #1 entry.max$ substring$
  1332.   'sort.key$ :=
  1333.  
  1334.   % The following line helps debug the program.  It shows what the sort.key$ is.
  1335.   % "%" sort.key$ * write$ newline$
  1336. }
  1337.  
  1338. % Here is the place that the actual executions of the labeling and sorting
  1339. % functions are done.
  1340.  
  1341.  
  1342. EXECUTE {initialize.extra.label.stuff} % initialize variables
  1343. ITERATE {bib.sort.order}               % set up the sorting keys
  1344. SORT        % by sort.label, year, title---giving final bibliography order
  1345. % Having sorted NOW we apply the extra letters at the end!
  1346. ITERATE {forward.pass}
  1347. REVERSE {reverse.pass}
  1348.  
  1349. FUNCTION {begin.bib}
  1350. { preamble$ empty$                % no \etalchar in apalike
  1351.     'skip$
  1352.     { preamble$ write$ newline$ }
  1353.   if$
  1354.   "\begin{thebibliography}{}" write$ newline$        % no labels in apalike
  1355. }
  1356.  
  1357. EXECUTE {begin.bib}
  1358.  
  1359. EXECUTE {init.state.consts}
  1360.  
  1361. ITERATE {call.type$}
  1362.  
  1363. FUNCTION {end.bib}
  1364. { newline$
  1365.   "\end{thebibliography}" write$ newline$
  1366. }
  1367.  
  1368. EXECUTE {end.bib}
  1369.